package com.ch.shopping.service.impl;

import com.ch.shopping.mapper.UserMapper;
import com.ch.shopping.pojo.User;
import com.ch.shopping.pojo.UserExample;
import com.ch.shopping.service.UserSevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author AuthorName
 * @create 2020-04-15 7:19
 */
@Service
public class UserServiceImpl implements UserSevice {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User queryById(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<User> queryUsersByLikeName(String name) {
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andUsernameLike("%"+name+"%");
        return userMapper.selectByExample(userExample);
    }
}
